using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using System;
namespace ICSharpCode.SharpZipLib.Zip.Compression
{
	internal class Class43
	{
		private const int int_0 = 0;
		private const int int_1 = 1;
		private const int int_2 = 2;
		private const int int_3 = 3;
		private const int int_4 = 4;
		private const int int_5 = 5;
		private static readonly int[] int_6 = new int[]
		{
			3,
			3,
			11
		};
		private static readonly int[] int_7 = new int[]
		{
			2,
			3,
			7
		};
		private static readonly int[] int_8 = new int[]
		{
			16,
			17,
			18,
			0,
			8,
			7,
			9,
			6,
			10,
			5,
			11,
			4,
			12,
			3,
			13,
			2,
			14,
			1,
			15
		};
		private byte[] byte_0;
		private byte[] byte_1;
		private InflaterHuffmanTree inflaterHuffmanTree_0;
		private int int_9;
		private int int_10;
		private int int_11;
		private int int_12;
		private int int_13;
		private int int_14;
		private byte byte_2;
		private int int_15;
		public bool method_0(StreamManipulator streamManipulator_0)
		{
			while (true)
			{
				switch (this.int_9)
				{
				case 0:
					this.int_10 = streamManipulator_0.PeekBits(5);
					if (this.int_10 >= 0)
					{
						this.int_10 += 257;
						streamManipulator_0.DropBits(5);
						this.int_9 = 1;
						goto IL_20B;
					}
					goto IL_2D6;
				case 1:
					goto IL_20B;
				case 2:
					goto IL_1B8;
				case 3:
					goto IL_17D;
				case 4:
					break;
				case 5:
					goto IL_06;
				default:
					continue;
				}
				IL_E3:
				int symbol;
				while (((symbol = this.inflaterHuffmanTree_0.GetSymbol(streamManipulator_0)) & -16) == 0)
				{
					this.byte_1[this.int_15++] = (this.byte_2 = (byte)symbol);
					if (this.int_15 == this.int_13)
					{
						goto IL_2F0;
					}
				}
				if (symbol >= 0)
				{
					if (symbol >= 17)
					{
						this.byte_2 = 0;
					}
					else
					{
						if (this.int_15 == 0)
						{
							goto IL_2EA;
						}
					}
					this.int_14 = symbol - 16;
					this.int_9 = 5;
					goto IL_06;
				}
				goto IL_2E6;
				IL_17D:
				while (this.int_15 < this.int_12)
				{
					int num = streamManipulator_0.PeekBits(3);
					if (num < 0)
					{
						goto IL_2E2;
					}
					streamManipulator_0.DropBits(3);
					this.byte_0[Class43.int_8[this.int_15]] = (byte)num;
					this.int_15++;
				}
				this.inflaterHuffmanTree_0 = new InflaterHuffmanTree(this.byte_0);
				this.byte_0 = null;
				this.int_15 = 0;
				this.int_9 = 4;
				goto IL_E3;
				IL_06:
				int bitCount = Class43.int_7[this.int_14];
				int num2 = streamManipulator_0.PeekBits(bitCount);
				if (num2 < 0)
				{
					goto IL_2F4;
				}
				streamManipulator_0.DropBits(bitCount);
				num2 += Class43.int_6[this.int_14];
				if (this.int_15 + num2 > this.int_13)
				{
					break;
				}
				while (num2-- > 0)
				{
					this.byte_1[this.int_15++] = this.byte_2;
				}
				if (this.int_15 != this.int_13)
				{
					this.int_9 = 4;
					continue;
				}
				goto IL_2FE;
				IL_1B8:
				this.int_12 = streamManipulator_0.PeekBits(4);
				if (this.int_12 >= 0)
				{
					this.int_12 += 4;
					streamManipulator_0.DropBits(4);
					this.byte_0 = new byte[19];
					this.int_15 = 0;
					this.int_9 = 3;
					goto IL_17D;
				}
				goto IL_2DE;
				IL_20B:
				this.int_11 = streamManipulator_0.PeekBits(5);
				if (this.int_11 >= 0)
				{
					this.int_11++;
					streamManipulator_0.DropBits(5);
					this.int_13 = this.int_10 + this.int_11;
					this.byte_1 = new byte[this.int_13];
					this.int_9 = 2;
					goto IL_1B8;
				}
				goto IL_2DA;
			}
			throw new SharpZipBaseException();
			IL_2D6:
			bool result = false;
			return result;
			IL_2DA:
			result = false;
			return result;
			IL_2DE:
			result = false;
			return result;
			IL_2E2:
			result = false;
			return result;
			IL_2E6:
			result = false;
			return result;
			IL_2EA:
			throw new SharpZipBaseException();
			IL_2F0:
			result = true;
			return result;
			IL_2F4:
			result = false;
			return result;
			IL_2FE:
			result = true;
			return result;
		}
		public InflaterHuffmanTree method_1()
		{
			byte[] array = new byte[this.int_10];
			Array.Copy(this.byte_1, 0, array, 0, this.int_10);
			return new InflaterHuffmanTree(array);
		}
		public InflaterHuffmanTree method_2()
		{
			byte[] array = new byte[this.int_11];
			Array.Copy(this.byte_1, this.int_10, array, 0, this.int_11);
			return new InflaterHuffmanTree(array);
		}
	}
}
